/****************************************************************************
*
* Description: Memory predicates
* Created at: 19.11.06 19:16:42 UTC
*
* $Revision$
*
****************************************************************************/
#pragma once

#if !defined(__memorypredicates_h__)
#define __memorypredicates_h__

#include <common/memory_block.h>

namespace common {
namespace memory {

/* Return true if memory block base equal to specified address.  */
template <
    class    T
>
class base_eq
{
public:
    base_eq(addr_t addr)
    	: addr_(addr)
    {}

    bool operator() (T& val)
    {
        return val.base() == addr_;
    }
private:
    addr_t  addr_;
};

/* Return true if memory block contains specified address.  */
template <
    class    T
>
class include_addr
{
public:
    include_addr(addr_t addr)
    	: addr_(addr)
    {}

    bool operator() (T& val)
    {
        addr_t  base = val.base();
        return (base <= addr_) && (base + val.size() > addr_);
    }
private:
    addr_t  addr_;
};

} /* End of memory  */
} /* End of common  */

#endif  /* End of __memorypredicates_h__.  */
